package com.itheima.Vue.web.manager.web;

import com.itheima.Vue.web.manager.pojo.Contact;
import com.itheima.Vue.web.manager.service.ContactService;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

@WebServlet("/FindSingleServlet")
public class FindSingleServlet extends HttpServlet {
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        this.doPost(request, response);
    }

    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        String idStr = request.getParameter("id");
        ContactService service = new ContactService();
        Contact Contact = service.getContactById(idStr);
        request.setAttribute("Contact",Contact);
        request.getRequestDispatcher("update.jsp").forward(request,response);
    }
}